const app = getApp();
const api = require('../../utils/api.js');
const util = require('../../utils/util.js');
Page({
	data: {
		windowWidth: app.systemInfo.windowWidth,
		windowHeight: app.systemInfo.windowHeight,
		pageNum:1,//当前页
		total:0,//总条数
		commentsList:[],
		ownerId:"",
		ownerName:"",
	},
	onLoad: function(options) {
		this.setData({
			ownerId: options.ownerId,
			ownerName: options.ownerName,
		});
		this.getCommentsList(options.ownerId);
	},
	getCommentsList: function(id) {
		let _this = this;
		api.commentsList({
			data: {
				ownerId: id,
				pageSize: "20",
				pageNum: _this.data.pageNum,
			},
			success: function(res) {
				if(res.data.code == 0) {
					
					res.data.list.rows.forEach(function(item){
						item.createTime = util.formatMinute(new Date(item.createTime));
					});
					_this.setData({
						commentsList: res.data.list.rows,
						total: res.data.list.total,
					});
				}
			},
		});
	},
	nextPage(){
		let _this = this;
		if(_this.data.total > _this.data.pageNum * 20){
			setTimeout(function(){
				_this.setData({
					pageNum: _this.data.pageNum + 1
				});
				_this.getCommentsList(_this.data.ownerId);
			},500);
		}else{
			console.log(_this.data.pageNum)
		}
	},

});